﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace KC.Tests.DataAccess
{
	[TestClass]
	public class GlobalTests : KC.DataAccess.Global.Global
	{
		[TestMethod]
		[TestCategory("Integration")]
		public void CallSql_Sproc1Test()
		{
			DataTable dt = CallSql_Sproc(KC.Constants.ConnectionStrings.MV7, @"xp_fixeddrives");
			Assert.IsTrue(dt.Rows.Count > 0);
		}
		[TestMethod]
		[TestCategory("Integration")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void CallSql_Sproc1NullTest1()
		{ DataTable dt = CallSql_Sproc(KC.Constants.ConnectionStrings.MV7, null); }
		[TestMethod]
		[TestCategory("Integration")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void CallSql_Sproc1NullTest2()
		{ DataTable dt = CallSql_Sproc(null, @"xp_fixeddrives"); }
		[TestMethod]
		[TestCategory("Integration")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void CallSql_Sproc1NullTest3()
		{ DataTable dt = CallSql_Sproc(null, null); }

		[TestMethod]
		[TestCategory("Integration")]
		public void CallSql_Sproc2Test()
		{
			DataTable dt = CallSql_Sproc(KC.Constants.ConnectionStrings.MV7, @"sp_statistics",
				new SqlParameter[] { new SqlParameter("@table_name", "Posts") });
			Assert.IsTrue(dt.Rows.Count > 0);
		}
		[TestMethod]
		[TestCategory("Integration")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void CallSql_Sproc2NullTest1()
		{
			DataTable dt = CallSql_Sproc(null, @"sp_statistics",
				new SqlParameter[] { new SqlParameter("@table_name", "Posts") });
			Assert.IsTrue(dt.Rows.Count > 0);
		}
		[TestMethod]
		[TestCategory("Integration")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void CallSql_Sproc2NullTest2()
		{
			DataTable dt = CallSql_Sproc(KC.Constants.ConnectionStrings.MV7, null,
				new SqlParameter[] { new SqlParameter("@table_name", "Posts") });
			Assert.IsTrue(dt.Rows.Count > 0);
		}
		[TestMethod]
		[TestCategory("Integration")]
		public void CallSql_Sproc2NullTest3()
		{
			DataTable dt = CallSql_Sproc(KC.Constants.ConnectionStrings.MV7, @"xp_fixeddrives", null);
			Assert.IsTrue(dt.Rows.Count > 0);
		}

		[TestMethod]
		[TestCategory("Integration")]
		public void CallSql_QueryTest()
		{
			DataTable dt = CallSql_Query(KC.Constants.ConnectionStrings.MV7, @"select getdate()");
			Assert.IsFalse(dt == null);
		}
		[TestMethod]
		[TestCategory("Unit")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void CallSql_QueryNullTest1()
		{
			CallSql_Query(null, @"select getdate()");
		}
		[TestMethod]
		[TestCategory("Unit")]
		[ExpectedException(typeof(ArgumentNullException))]
		public void CallSql_QueryNullTest2()
		{
			CallSql_Query(KC.Constants.ConnectionStrings.MV7, null);
		}

	}
}
